function changeMode() {
    geneListPanel.removeAll()
    locPanel = new visualPanels[Ext.getCmp('tabPanel').getActiveTab().title].locationGrid()
    geneListPanel.add(locPanel);
    geneListPanel.doLayout();
    //locPanel.onChangeSelect()
}

function updateDisplay(reset) {
    Ext.getCmp('tabPanel').getActiveTab().display(reset);
}

function get_locations(query, mask, update_location) {
    mask.show();
    //console.log(query)
    var locs = query.trim().toLowerCase().split(/,| |\n/);
    var cached = new Array();
    for (i in locations) {
        cached.push(i.toLowerCase());
        cached.push(locations[i].genename.toLowerCase());
    }
    var q = new Array();
    Ext.each(locs,
    function(i) {
        if (cached.indexOf(i) == -1)
        q.push(i);
    });
    if (q.length == 0 | query.length == 0) {
        mask.hide();
        return;
    }
    var params = {
        locs: q.join(',')
    };
    Ext.applyIf(params, config[current_genome].search.additional_params);
    Ext.Ajax.request({
        url: config[current_genome].search.url,
        method: 'GET',
				xdomain:true,
        params: params,
        scope: this,
        success: function(response, opts) {
            if (response.responseText.length == 0) {
                mask.hide();
                return;
            }
            var d = Ext.decode(response.responseText);
            for (j in d) {
                //d[j].genename = d[j].genename.replace('.','_')
                locations[d[j].location_id] = d[j];
            }
            Ext.getCmp('locationGrid').addResults(update_location);

            sampleGrid.addResults();
            mask.hide();

        },
        failure: function(response, opts) {
            console.log('server-side failure with status code ' + response.status);
            mask.hide();
        }
    });
}


function select_genome(cb, checked) {
    if (cb.checked != true) return;
    current_genome = cb.id;
    sampleGrid.getSamples();
    
    selected_tracks = new Array();
    current_loc = null;
    locations = {};
    addVisualPanels()
    
    //Ext.getCmp('locationGrid').addResults()
    //updateDisplay(true)

}

